home *** CD-ROM | disk | FTP | other *** search
/ Assassins - Ultimate CD Games Collection 4 / Assassins 4 (1999)(Weird Science).iso / mui / mui_developer / c / examples / popup.c < prev    next >
C/C++ Source or Header  |  1997-03-10  |  5KB  |  197 lines

  1. #include "demo.h"
  2.  
  3.  
  4. SAVEDS ASM LONG StrObjFunc(REG(a2) Object *pop,REG(a1) Object *str)
  5. {
  6.     char *x,*s;
  7.     int i;
  8.  
  9.     get(str,MUIA_String_Contents,&s);
  10.  
  11.     for (i=0;;i++)
  12.     {
  13.         DoMethod(pop,MUIM_List_GetEntry,i,&x);
  14.         if (!x)
  15.         {
  16.             set(pop,MUIA_List_Active,MUIV_List_Active_Off);
  17.             break;
  18.         }
  19.         else if (!stricmp(x,s))
  20.         {
  21.             set(pop,MUIA_List_Active,i);
  22.             break;
  23.         }
  24.     }
  25.     return(TRUE);
  26. }
  27.  
  28.  
  29. SAVEDS ASM VOID ObjStrFunc(REG(a2) Object *pop,REG(a1) Object *str)
  30. {
  31.     char *x;
  32.     DoMethod(pop,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&x);
  33.     set(str,MUIA_String_Contents,x);
  34. }
  35.  
  36.  
  37. SAVEDS ASM VOID WindowFunc(REG(a2) Object *pop,REG(a1) Object *win)
  38. {
  39.     set(win,MUIA_Window_DefaultObject,pop);
  40. }
  41.  
  42.  
  43. static const char *PopNames[] =
  44. {
  45.     "Stefan Becker",
  46.     "Dirk Federlein",
  47.     "Georg Heßmann",
  48.     "Martin Horneffer",
  49.     "Martin Huttenloher",
  50.     "Kai Iske",
  51.     "Oliver Kilian",
  52.     "Franke Mariak",
  53.     "Klaus Melchior",
  54.     "Armin Sander",
  55.     "Matthias Scheler",
  56.     "Andreas Schildbach",
  57.     "Wolfgang Schildbach",
  58.     "Christian Scholz",
  59.     "Stefan Sommerfeld",
  60.     "Markus Stipp",
  61.     "Henri Veistera",
  62.     "Albert Weinert",
  63.     "Michael-W. Hohmann", 
  64.     "Stefan Burstroem",
  65.     NULL
  66. };
  67.  
  68.  
  69. int main(int argc,char *argv[])
  70. {
  71.     static const struct Hook StrObjHook = { { NULL,NULL },(VOID *)StrObjFunc,NULL,NULL };
  72.     static const struct Hook ObjStrHook = { { NULL,NULL },(VOID *)ObjStrFunc,NULL,NULL };
  73.     static const struct Hook WindowHook = { { NULL,NULL },(VOID *)WindowFunc,NULL,NULL };
  74.     APTR app,window,pop1,pop2,pop3,pop4,pop5,plist;
  75.     ULONG signals;
  76.     BOOL running = TRUE;
  77.  
  78.     init();
  79.  
  80.     app = ApplicationObject,
  81.         MUIA_Application_Title      , "Popup-Demo",
  82.         MUIA_Application_Version    , "$VER: Popup-Demo 19.5 (12.02.97)",
  83.         MUIA_Application_Copyright  , "©1993, Stefan Stuntz",
  84.         MUIA_Application_Author     , "Stefan Stuntz",
  85.         MUIA_Application_Description, "Demostrate popup objects.",
  86.         MUIA_Application_Base       , "POPUP",
  87.  
  88.         SubWindow, window = WindowObject,
  89.             MUIA_Window_Title, "Popup Objects",
  90.             MUIA_Window_ID   , MAKE_ID('P','O','P','P'),
  91.             WindowContents, VGroup,
  92.  
  93.                 Child, ColGroup(2),
  94.  
  95.                     Child, KeyLabel2("File:",'f'),
  96.                     Child, pop1 = PopaslObject,
  97.                         MUIA_Popstring_String, KeyString(0,256,'f'),
  98.                         MUIA_Popstring_Button, PopButton(MUII_PopFile),
  99.                         ASLFR_TitleText, "Please select a file...",
  100.                         End,
  101.  
  102.                     Child, KeyLabel2("Drawer:",'d'),
  103.                     Child, pop2 = PopaslObject,
  104.                         MUIA_Popstring_String, KeyString(0,256,'d'),
  105.                         MUIA_Popstring_Button, PopButton(MUII_PopDrawer),
  106.                         ASLFR_TitleText  , "Please select a drawer...",
  107.                         ASLFR_DrawersOnly, TRUE,
  108.                         End,
  109.  
  110.                     Child, KeyLabel2("Font:",'o'),
  111.                     Child, pop3 = PopaslObject,
  112.                         MUIA_Popstring_String, KeyString(0,80,'o'),
  113.                         MUIA_Popstring_Button, PopButton(MUII_PopUp),
  114.                         MUIA_Popasl_Type , ASL_FontRequest,
  115.                         ASLFO_TitleText  , "Please select a font...",
  116.                         End,
  117.  
  118.                     Child, KeyLabel2("Fixed Font:",'i'),
  119.                     Child, pop4 = PopaslObject,
  120.                         MUIA_Popstring_String, KeyString(0,80,'i'),
  121.                         MUIA_Popstring_Button, PopButton(MUII_PopUp),
  122.                         MUIA_Popasl_Type , ASL_FontRequest,
  123.                         ASLFO_TitleText  , "Please select a fixed font...",
  124.                         ASLFO_FixedWidthOnly, TRUE,
  125.                         End,
  126.  
  127.                     Child, KeyLabel2("Thanks To:",'n'),
  128.                     Child, pop5 = PopobjectObject,
  129.                         MUIA_Popstring_String, KeyString(0,60,'n'),
  130.                         MUIA_Popstring_Button, PopButton(MUII_PopUp),
  131.                         MUIA_Popobject_StrObjHook, &StrObjHook,
  132.                         MUIA_Popobject_ObjStrHook, &ObjStrHook,
  133.                         MUIA_Popobject_WindowHook, &WindowHook,
  134.                         MUIA_Popobject_Object, plist = ListviewObject,
  135.                             MUIA_Listview_List, ListObject,
  136.                                 InputListFrame,
  137.                                 MUIA_List_SourceArray, PopNames,
  138.                                 End,
  139.                             End,
  140.                         End,
  141.                     End,
  142.                 End,
  143.             End,
  144.         End;
  145.  
  146.     if (!app)
  147.         fail(app,"Failed to create Application.");
  148.  
  149.     DoMethod(window,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
  150.         app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  151.  
  152.     DoMethod(window,MUIM_Window_SetCycleChain,pop1,pop2,pop3,pop4,pop5,NULL);
  153.  
  154.     /* A double click terminates the popping list with a successful return value. */
  155.     DoMethod(plist,MUIM_Notify,MUIA_Listview_DoubleClick,TRUE,
  156.         pop5,2,MUIM_Popstring_Close,TRUE);
  157.  
  158.  
  159. /*
  160. ** Input loop...
  161. */
  162.  
  163.     set(window,MUIA_Window_Open,TRUE);
  164.  
  165.     while (running)
  166.     {
  167.         switch (DoMethod(app,MUIM_Application_Input,&signals))
  168.         {
  169.             case MUIV_Application_ReturnID_Quit:
  170.             {
  171.              LONG active;
  172.  
  173.                 get(pop1,MUIA_Popasl_Active,&active);
  174.                 if (!active) get(pop2,MUIA_Popasl_Active,&active);
  175.                 if (!active) get(pop3,MUIA_Popasl_Active,&active);
  176.                 if (!active) get(pop4,MUIA_Popasl_Active,&active);
  177.  
  178.                 if (active)
  179.                     MUI_Request(app,window,0,NULL,"OK","Cannot quit now, still\nsome asl popups opened.");
  180.                 else
  181.                     running = FALSE;
  182.             }
  183.             break;
  184.         }
  185.  
  186.         if (running && signals) Wait(signals);
  187.     }
  188.  
  189.     set(window,MUIA_Window_Open,FALSE);
  190.  
  191. /*
  192. ** Shut down...
  193. */
  194.  
  195.     fail(app,NULL);
  196. }
  197.